package com.yubest.remotecall.controller;

import cn.hutool.http.HttpUtil;
import com.yubest.remotecall.service.HelloServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class HelloController {

    @Autowired
    private HelloServiceFeign helloServiceFeign;

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping(value = "/hello")
    public Object hello() {
        return helloServiceFeign.hello();
    }

    @GetMapping(value = "/hello2")
    public Object hello2() {
        return restTemplate.getForEntity("http://spring-cloud-server1/hello", String.class).getBody();
    }

    @GetMapping(value = "/hello3")
    public Object hello3() {
        return HttpUtil.get("http://localhost:9001/hello");
    }
}
